<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="公司代码" prop="tenantId">
        <el-input
          v-model="queryParams.tenantId"
          placeholder="请输入公司代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司名称" prop="gcmc">
        <el-input
          v-model="queryParams.gcmc"
          placeholder="请输入公司名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="半成品子图编号" prop="bcpztbh">
        <el-input
          v-model="queryParams.bcpztbh"
          placeholder="请输入半成品子图编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="半成品名称" prop="bcpmc">
        <el-input
          v-model="queryParams.bcpmc"
          placeholder="请输入半成品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料大类" prop="materialCategory">
        <el-input
          v-model="queryParams.materialCategory"
          placeholder="请输入物料大类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格" prop="gg">
        <el-input
          v-model="queryParams.gg"
          placeholder="请输入规格"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用量" prop="yl">
        <el-input
          v-model="queryParams.yl"
          placeholder="请输入用量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品条码号" prop="cptmh">
        <el-input
          v-model="queryParams.cptmh"
          placeholder="请输入产品条码号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="半成品条码号" prop="bcptmh">
        <el-input
          v-model="queryParams.bcptmh"
          placeholder="请输入半成品条码号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备名称" prop="sbmc">
        <el-input
          v-model="queryParams.sbmc"
          placeholder="请输入设备名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备编号" prop="sbbh">
        <el-input
          v-model="queryParams.sbbh"
          placeholder="请输入设备编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备功率" prop="sbgl">
        <el-input
          v-model="queryParams.sbgl"
          placeholder="请输入设备功率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品号" prop="cph">
        <el-input
          v-model="queryParams.cph"
          placeholder="请输入产品号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单位" prop="dw">
        <el-input
          v-model="queryParams.dw"
          placeholder="请输入单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计算数量" prop="jssl">
        <el-input
          v-model="queryParams.jssl"
          placeholder="请输入计算数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="体积" prop="tj">
        <el-input
          v-model="queryParams.tj"
          placeholder="请输入体积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="重量" prop="zl">
        <el-input
          v-model="queryParams.zl"
          placeholder="请输入重量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单价" prop="dj">
        <el-input
          v-model="queryParams.dj"
          placeholder="请输入单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="金额" prop="je">
        <el-input
          v-model="queryParams.je"
          placeholder="请输入金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="料损耗重量1" prop="lshzl1">
        <el-input
          v-model="queryParams.lshzl1"
          placeholder="请输入料损耗重量1"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="料损耗重量2" prop="lshzl2">
        <el-input
          v-model="queryParams.lshzl2"
          placeholder="请输入料损耗重量2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="料损耗重量3" prop="lshzl3">
        <el-input
          v-model="queryParams.lshzl3"
          placeholder="请输入料损耗重量3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="料损耗重量4" prop="lshzl4">
        <el-input
          v-model="queryParams.lshzl4"
          placeholder="请输入料损耗重量4"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品组合号" prop="cpzhh">
        <el-input
          v-model="queryParams.cpzhh"
          placeholder="请输入产品组合号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="料损耗重量5" prop="lshzl5">
        <el-input
          v-model="queryParams.lshzl5"
          placeholder="请输入料损耗重量5"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计件单价" prop="jjdj">
        <el-input
          v-model="queryParams.jjdj"
          placeholder="请输入计件单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="基本工资" prop="jbgz">
        <el-input
          v-model="queryParams.jbgz"
          placeholder="请输入基本工资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="福利费用" prop="flify">
        <el-input
          v-model="queryParams.flify"
          placeholder="请输入福利费用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用电量" prop="ydl">
        <el-input
          v-model="queryParams.ydl"
          placeholder="请输入用电量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="电单价" prop="ddj">
        <el-input
          v-model="queryParams.ddj"
          placeholder="请输入电单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用电金额" prop="ydje">
        <el-input
          v-model="queryParams.ydje"
          placeholder="请输入用电金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用水量" prop="ysl">
        <el-input
          v-model="queryParams.ysl"
          placeholder="请输入用水量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="水单价" prop="sdj">
        <el-input
          v-model="queryParams.sdj"
          placeholder="请输入水单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用水金额" prop="ysje">
        <el-input
          v-model="queryParams.ysje"
          placeholder="请输入用水金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品编号" prop="cpbh">
        <el-input
          v-model="queryParams.cpbh"
          placeholder="请输入产品编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用燃气量" prop="yrql">
        <el-input
          v-model="queryParams.yrql"
          placeholder="请输入用燃气量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="燃气单价" prop="rqdj">
        <el-input
          v-model="queryParams.rqdj"
          placeholder="请输入燃气单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用燃气金额" prop="yrqje">
        <el-input
          v-model="queryParams.yrqje"
          placeholder="请输入用燃气金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用油量" prop="yyl">
        <el-input
          v-model="queryParams.yyl"
          placeholder="请输入用油量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="油单价" prop="ydj">
        <el-input
          v-model="queryParams.ydj"
          placeholder="请输入油单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用油金额" prop="yyje">
        <el-input
          v-model="queryParams.yyje"
          placeholder="请输入用油金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备折旧" prop="sbzj">
        <el-input
          v-model="queryParams.sbzj"
          placeholder="请输入设备折旧"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="刀具费用" prop="djfy">
        <el-input
          v-model="queryParams.djfy"
          placeholder="请输入刀具费用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="辅料费用" prop="flfy">
        <el-input
          v-model="queryParams.flfy"
          placeholder="请输入辅料费用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="包装费用" prop="bzfy">
        <el-input
          v-model="queryParams.bzfy"
          placeholder="请输入包装费用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品子编码号" prop="cpzbmh">
        <el-input
          v-model="queryParams.cpzbmh"
          placeholder="请输入产品子编码号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="料废损失金额" prop="lfssje">
        <el-input
          v-model="queryParams.lfssje"
          placeholder="请输入料废损失金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合计费用" prop="hjfy">
        <el-input
          v-model="queryParams.hjfy"
          placeholder="请输入合计费用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品名称" prop="cpmc">
        <el-input
          v-model="queryParams.cpmc"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工序编号" prop="gxbh">
        <el-input
          v-model="queryParams.gxbh"
          placeholder="请输入工序编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工序名称" prop="gxmc">
        <el-input
          v-model="queryParams.gxmc"
          placeholder="请输入工序名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="半成品编号" prop="bcpbh">
        <el-input
          v-model="queryParams.bcpbh"
          placeholder="请输入半成品编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:ncProductStaCost:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:ncProductStaCost:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:ncProductStaCost:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:ncProductStaCost:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ncProductStaCostList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="id" />
      <el-table-column label="公司代码" align="center" prop="tenantId" />
      <el-table-column label="公司名称" align="center" prop="gcmc" />
      <el-table-column label="半成品子图编号" align="center" prop="bcpztbh" />
      <el-table-column label="半成品名称" align="center" prop="bcpmc" />
      <el-table-column label="物料大类" align="center" prop="materialCategory" />
      <el-table-column label="规格" align="center" prop="gg" />
      <el-table-column label="用量" align="center" prop="yl" />
      <el-table-column label="产品条码号" align="center" prop="cptmh" />
      <el-table-column label="半成品条码号" align="center" prop="bcptmh" />
      <el-table-column label="设备名称" align="center" prop="sbmc" />
      <el-table-column label="设备编号" align="center" prop="sbbh" />
      <el-table-column label="设备功率" align="center" prop="sbgl" />
      <el-table-column label="产品号" align="center" prop="cph" />
      <el-table-column label="单位" align="center" prop="dw" />
      <el-table-column label="计算数量" align="center" prop="jssl" />
      <el-table-column label="体积" align="center" prop="tj" />
      <el-table-column label="重量" align="center" prop="zl" />
      <el-table-column label="单价" align="center" prop="dj" />
      <el-table-column label="金额" align="center" prop="je" />
      <el-table-column label="料损耗重量1" align="center" prop="lshzl1" />
      <el-table-column label="料损耗重量2" align="center" prop="lshzl2" />
      <el-table-column label="料损耗重量3" align="center" prop="lshzl3" />
      <el-table-column label="料损耗重量4" align="center" prop="lshzl4" />
      <el-table-column label="产品组合号" align="center" prop="cpzhh" />
      <el-table-column label="料损耗重量5" align="center" prop="lshzl5" />
      <el-table-column label="计件单价" align="center" prop="jjdj" />
      <el-table-column label="基本工资" align="center" prop="jbgz" />
      <el-table-column label="福利费用" align="center" prop="flify" />
      <el-table-column label="用电量" align="center" prop="ydl" />
      <el-table-column label="电单价" align="center" prop="ddj" />
      <el-table-column label="用电金额" align="center" prop="ydje" />
      <el-table-column label="用水量" align="center" prop="ysl" />
      <el-table-column label="水单价" align="center" prop="sdj" />
      <el-table-column label="用水金额" align="center" prop="ysje" />
      <el-table-column label="产品编号" align="center" prop="cpbh" />
      <el-table-column label="用燃气量" align="center" prop="yrql" />
      <el-table-column label="燃气单价" align="center" prop="rqdj" />
      <el-table-column label="用燃气金额" align="center" prop="yrqje" />
      <el-table-column label="用油量" align="center" prop="yyl" />
      <el-table-column label="油单价" align="center" prop="ydj" />
      <el-table-column label="用油金额" align="center" prop="yyje" />
      <el-table-column label="设备折旧" align="center" prop="sbzj" />
      <el-table-column label="刀具费用" align="center" prop="djfy" />
      <el-table-column label="辅料费用" align="center" prop="flfy" />
      <el-table-column label="包装费用" align="center" prop="bzfy" />
      <el-table-column label="产品子编码号" align="center" prop="cpzbmh" />
      <el-table-column label="料废损失金额" align="center" prop="lfssje" />
      <el-table-column label="合计费用" align="center" prop="hjfy" />
      <el-table-column label="产品名称" align="center" prop="cpmc" />
      <el-table-column label="工序编号" align="center" prop="gxbh" />
      <el-table-column label="工序名称" align="center" prop="gxmc" />
      <el-table-column label="半成品编号" align="center" prop="bcpbh" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:ncProductStaCost:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:ncProductStaCost:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改产品工位成本对话框 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="公司代码" prop="tenantId">
          <el-input v-model="form.tenantId" placeholder="请输入公司代码" />
        </el-form-item>
        <el-form-item label="公司名称" prop="gcmc">
          <el-input v-model="form.gcmc" placeholder="请输入公司名称" />
        </el-form-item>
        <el-form-item label="半成品子图编号" prop="bcpztbh">
          <el-input v-model="form.bcpztbh" placeholder="请输入半成品子图编号" />
        </el-form-item>
        <el-form-item label="半成品名称" prop="bcpmc">
          <el-input v-model="form.bcpmc" placeholder="请输入半成品名称" />
        </el-form-item>
        <el-form-item label="物料大类" prop="materialCategory">
          <el-input v-model="form.materialCategory" placeholder="请输入物料大类" />
        </el-form-item>
        <el-form-item label="规格" prop="gg">
          <el-input v-model="form.gg" placeholder="请输入规格" />
        </el-form-item>
        <el-form-item label="用量" prop="yl">
          <el-input v-model="form.yl" placeholder="请输入用量" />
        </el-form-item>
        <el-form-item label="产品条码号" prop="cptmh">
          <el-input v-model="form.cptmh" placeholder="请输入产品条码号" />
        </el-form-item>
        <el-form-item label="半成品条码号" prop="bcptmh">
          <el-input v-model="form.bcptmh" placeholder="请输入半成品条码号" />
        </el-form-item>
        <el-form-item label="设备名称" prop="sbmc">
          <el-input v-model="form.sbmc" placeholder="请输入设备名称" />
        </el-form-item>
        <el-form-item label="设备编号" prop="sbbh">
          <el-input v-model="form.sbbh" placeholder="请输入设备编号" />
        </el-form-item>
        <el-form-item label="设备功率" prop="sbgl">
          <el-input v-model="form.sbgl" placeholder="请输入设备功率" />
        </el-form-item>
        <el-form-item label="产品号" prop="cph">
          <el-input v-model="form.cph" placeholder="请输入产品号" />
        </el-form-item>
        <el-form-item label="单位" prop="dw">
          <el-input v-model="form.dw" placeholder="请输入单位" />
        </el-form-item>
        <el-form-item label="计算数量" prop="jssl">
          <el-input v-model="form.jssl" placeholder="请输入计算数量" />
        </el-form-item>
        <el-form-item label="体积" prop="tj">
          <el-input v-model="form.tj" placeholder="请输入体积" />
        </el-form-item>
        <el-form-item label="重量" prop="zl">
          <el-input v-model="form.zl" placeholder="请输入重量" />
        </el-form-item>
        <el-form-item label="单价" prop="dj">
          <el-input v-model="form.dj" placeholder="请输入单价" />
        </el-form-item>
        <el-form-item label="金额" prop="je">
          <el-input v-model="form.je" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="料损耗重量1" prop="lshzl1">
          <el-input v-model="form.lshzl1" placeholder="请输入料损耗重量1" />
        </el-form-item>
        <el-form-item label="料损耗重量2" prop="lshzl2">
          <el-input v-model="form.lshzl2" placeholder="请输入料损耗重量2" />
        </el-form-item>
        <el-form-item label="料损耗重量3" prop="lshzl3">
          <el-input v-model="form.lshzl3" placeholder="请输入料损耗重量3" />
        </el-form-item>
        <el-form-item label="料损耗重量4" prop="lshzl4">
          <el-input v-model="form.lshzl4" placeholder="请输入料损耗重量4" />
        </el-form-item>
        <el-form-item label="产品组合号" prop="cpzhh">
          <el-input v-model="form.cpzhh" placeholder="请输入产品组合号" />
        </el-form-item>
        <el-form-item label="料损耗重量5" prop="lshzl5">
          <el-input v-model="form.lshzl5" placeholder="请输入料损耗重量5" />
        </el-form-item>
        <el-form-item label="计件单价" prop="jjdj">
          <el-input v-model="form.jjdj" placeholder="请输入计件单价" />
        </el-form-item>
        <el-form-item label="基本工资" prop="jbgz">
          <el-input v-model="form.jbgz" placeholder="请输入基本工资" />
        </el-form-item>
        <el-form-item label="福利费用" prop="flify">
          <el-input v-model="form.flify" placeholder="请输入福利费用" />
        </el-form-item>
        <el-form-item label="用电量" prop="ydl">
          <el-input v-model="form.ydl" placeholder="请输入用电量" />
        </el-form-item>
        <el-form-item label="电单价" prop="ddj">
          <el-input v-model="form.ddj" placeholder="请输入电单价" />
        </el-form-item>
        <el-form-item label="用电金额" prop="ydje">
          <el-input v-model="form.ydje" placeholder="请输入用电金额" />
        </el-form-item>
        <el-form-item label="用水量" prop="ysl">
          <el-input v-model="form.ysl" placeholder="请输入用水量" />
        </el-form-item>
        <el-form-item label="水单价" prop="sdj">
          <el-input v-model="form.sdj" placeholder="请输入水单价" />
        </el-form-item>
        <el-form-item label="用水金额" prop="ysje">
          <el-input v-model="form.ysje" placeholder="请输入用水金额" />
        </el-form-item>
        <el-form-item label="产品编号" prop="cpbh">
          <el-input v-model="form.cpbh" placeholder="请输入产品编号" />
        </el-form-item>
        <el-form-item label="用燃气量" prop="yrql">
          <el-input v-model="form.yrql" placeholder="请输入用燃气量" />
        </el-form-item>
        <el-form-item label="燃气单价" prop="rqdj">
          <el-input v-model="form.rqdj" placeholder="请输入燃气单价" />
        </el-form-item>
        <el-form-item label="用燃气金额" prop="yrqje">
          <el-input v-model="form.yrqje" placeholder="请输入用燃气金额" />
        </el-form-item>
        <el-form-item label="用油量" prop="yyl">
          <el-input v-model="form.yyl" placeholder="请输入用油量" />
        </el-form-item>
        <el-form-item label="油单价" prop="ydj">
          <el-input v-model="form.ydj" placeholder="请输入油单价" />
        </el-form-item>
        <el-form-item label="用油金额" prop="yyje">
          <el-input v-model="form.yyje" placeholder="请输入用油金额" />
        </el-form-item>
        <el-form-item label="设备折旧" prop="sbzj">
          <el-input v-model="form.sbzj" placeholder="请输入设备折旧" />
        </el-form-item>
        <el-form-item label="刀具费用" prop="djfy">
          <el-input v-model="form.djfy" placeholder="请输入刀具费用" />
        </el-form-item>
        <el-form-item label="辅料费用" prop="flfy">
          <el-input v-model="form.flfy" placeholder="请输入辅料费用" />
        </el-form-item>
        <el-form-item label="包装费用" prop="bzfy">
          <el-input v-model="form.bzfy" placeholder="请输入包装费用" />
        </el-form-item>
        <el-form-item label="产品子编码号" prop="cpzbmh">
          <el-input v-model="form.cpzbmh" placeholder="请输入产品子编码号" />
        </el-form-item>
        <el-form-item label="料废损失金额" prop="lfssje">
          <el-input v-model="form.lfssje" placeholder="请输入料废损失金额" />
        </el-form-item>
        <el-form-item label="合计费用" prop="hjfy">
          <el-input v-model="form.hjfy" placeholder="请输入合计费用" />
        </el-form-item>
        <el-form-item label="产品名称" prop="cpmc">
          <el-input v-model="form.cpmc" placeholder="请输入产品名称" />
        </el-form-item>
        <el-form-item label="工序编号" prop="gxbh">
          <el-input v-model="form.gxbh" placeholder="请输入工序编号" />
        </el-form-item>
        <el-form-item label="工序名称" prop="gxmc">
          <el-input v-model="form.gxmc" placeholder="请输入工序名称" />
        </el-form-item>
        <el-form-item label="半成品编号" prop="bcpbh">
          <el-input v-model="form.bcpbh" placeholder="请输入半成品编号" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listNcProductStaCost, getNcProductStaCost, delNcProductStaCost, addNcProductStaCost, updateNcProductStaCost } from "@/api/business/ncProductStaCost";

export default {
  name: "NcProductStaCost",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产品工位成本表格数据
      ncProductStaCostList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        tenantId: null,
        gcmc: null,
        bcpztbh: null,
        bcpmc: null,
        materialCategory: null,
        gg: null,
        yl: null,
        cptmh: null,
        bcptmh: null,
        sbmc: null,
        sbbh: null,
        sbgl: null,
        cph: null,
        dw: null,
        jssl: null,
        tj: null,
        zl: null,
        dj: null,
        je: null,
        lshzl1: null,
        lshzl2: null,
        lshzl3: null,
        lshzl4: null,
        cpzhh: null,
        lshzl5: null,
        jjdj: null,
        jbgz: null,
        flify: null,
        ydl: null,
        ddj: null,
        ydje: null,
        ysl: null,
        sdj: null,
        ysje: null,
        cpbh: null,
        yrql: null,
        rqdj: null,
        yrqje: null,
        yyl: null,
        ydj: null,
        yyje: null,
        sbzj: null,
        djfy: null,
        flfy: null,
        bzfy: null,
        cpzbmh: null,
        lfssje: null,
        hjfy: null,
        cpmc: null,
        gxbh: null,
        gxmc: null,
        bcpbh: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询产品工位成本列表 */
    getList() {
      this.loading = true;
      listNcProductStaCost(this.queryParams).then(response => {
        this.ncProductStaCostList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        tenantId: null,
        gcmc: null,
        bcpztbh: null,
        bcpmc: null,
        materialCategory: null,
        gg: null,
        yl: null,
        cptmh: null,
        bcptmh: null,
        sbmc: null,
        sbbh: null,
        sbgl: null,
        cph: null,
        dw: null,
        jssl: null,
        tj: null,
        zl: null,
        dj: null,
        je: null,
        lshzl1: null,
        lshzl2: null,
        lshzl3: null,
        lshzl4: null,
        cpzhh: null,
        lshzl5: null,
        jjdj: null,
        jbgz: null,
        flify: null,
        ydl: null,
        ddj: null,
        ydje: null,
        ysl: null,
        sdj: null,
        ysje: null,
        cpbh: null,
        yrql: null,
        rqdj: null,
        yrqje: null,
        yyl: null,
        ydj: null,
        yyje: null,
        sbzj: null,
        djfy: null,
        flfy: null,
        bzfy: null,
        cpzbmh: null,
        lfssje: null,
        hjfy: null,
        cpmc: null,
        gxbh: null,
        gxmc: null,
        bcpbh: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加产品工位成本";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getNcProductStaCost(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改产品工位成本";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateNcProductStaCost(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addNcProductStaCost(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除产品工位成本编号为"' + ids + '"的数据项？').then(function() {
        return delNcProductStaCost(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/ncProductStaCost/export', {
        ...this.queryParams
      }, `ncProductStaCost_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
